<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "archive_item".
 *
 * @property int $id
 * @property int $id_section
 * @property string $title
 * @property string $m_number
 * @property int $is_Digitized
 * @property string $description
 *
 * @property ArchiveSection $section
 */
class ArchiveItem extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'archive_item';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['id_section'], 'required'],
            [['id_section', 'is_Digitized'], 'integer'],
            [['description', 'register'], 'string'],
            [['title'], 'string', 'max' => 255],
            [['m_number'], 'string', 'max' => 40],
            [['id_section'], 'exist', 'skipOnError' => true, 'targetClass' => ArchiveSection::className(), 'targetAttribute' => ['id_section' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'id_section' => 'Раздел',
            'title' => 'Название',
            'm_number' => 'Номер папки',
            'is_Digitized' => 'Оцифровано',
            'description' => 'Краткое описание',
            'register' => 'Опись',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSection()
    {
        return $this->hasOne(ArchiveSection::className(), ['id' => 'id_section']);
    }
}
